package com.biz.mq.config;

import com.biz.mq.service.*;
import com.biz.mq.service.impl.*;
import org.apache.rocketmq.spring.core.*;
import org.springframework.amqp.core.*;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.context.annotation.*;

/**
 * @Description mq-自动适配切换配置
 *
 * @Author liuxi
 * @Date 2024/6/30
 **/
public class MessageSenderConfig {

    @Bean
    @ConditionalOnProperty("rocketmq.name-server")
    public QueueService rocketMQMessageSender(RocketMQTemplate rocketMQTemplate) {
        return new RocketMQMessageSender(rocketMQTemplate);
    }

    @Bean
    @ConditionalOnProperty("spring.rabbitmq.host")
    public QueueService rabbitMQMessageSender(AmqpTemplate amqpTemplate) {
        return new RabbitMQMessageSender(amqpTemplate);
    }
}
